#include "common.h"
#include "d_oneround.h"
#include "basicoperation.h"
#include <stdio.h>

void d_oneround( word *state , word roundkey1 , word roundkey2 )
{
	word tmp ; 
	tmp = state[3] ;
	state[3] = state[2] ;
	state[2] = state[1] ;
	state[1] = state[0] ;
	state[0] = tmp ;

	word u , t ;
	u = rotate_left( state[3]*(2*state[3]+1) , last_5_bits(lgw) ) ;
	t = rotate_left( state[1]*(2*state[1]+1) , last_5_bits(lgw) ) ;
	state[2] = (rotate_right( state[2] - roundkey1 , last_5_bits(t) )) ^ u ; 
	state[0] = (rotate_right( state[0] - roundkey2 , last_5_bits(u) )) ^ t ;
	for ( int i = 0 ; i <= 3 ; ++i )
	{
		printf( "%x " , state[i] ) ;
	}
	printf( "\n" ) ;
}